home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 March / Pc Users extra 6.iso / pshare95 / prog / pvie / pview.exe / data.1 / treedlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-23  |  4.2 KB  |  161 lines

  1. // TreeDialog.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "allctls.h"
  6. #include "TreeDlg.h"
  7. #include "branch.h"
  8. #include "ptreedef.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CTreeDialog dialog
  18.  
  19.  
  20. CTreeDialog::CTreeDialog(CWnd* pParent /*=NULL*/)
  21.     : CDialog(CTreeDialog::IDD, pParent)
  22. {
  23.     //{{AFX_DATA_INIT(CTreeDialog)
  24.     //}}AFX_DATA_INIT
  25. }
  26.  
  27.  
  28. void CTreeDialog::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CTreeDialog)
  32.     DDX_Control(pDX, IDC_PVTREEVIEWCTRL1, m_treeview);
  33.     //}}AFX_DATA_MAP
  34. }
  35.  
  36.  
  37. BEGIN_MESSAGE_MAP(CTreeDialog, CDialog)
  38.     //{{AFX_MSG_MAP(CTreeDialog)
  39.     //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CTreeDialog message handlers
  44.  
  45. BOOL CTreeDialog::OnInitDialog()
  46. {
  47.     CDialog::OnInitDialog();
  48.  
  49.     // TODO: Add extra initialization here
  50.     CBranch parent;
  51.  
  52.     //root = m_treeview.GetBranches();
  53.  
  54.     parent = m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "Parent Node");
  55.     parent.Select(pvtNode);
  56.     parent.Add(pvtPositionInOrder, 0, "Child Node 1 ");
  57.     parent.Add(pvtPositionInOrder, 0, "Child Node 2");
  58.     parent.Add(pvtPositionInOrder, 0, "Child Node 3");
  59.     parent = m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "Parent Node");
  60.     parent.Add(pvtPositionInOrder, 0, "Child Node 4");
  61.  
  62.     return TRUE;  // return TRUE unless you set the focus to a control
  63.                   // EXCEPTION: OCX Property Pages should return FALSE
  64. }
  65.  
  66. BEGIN_EVENTSINK_MAP(CTreeDialog, CDialog)
  67.     //{{AFX_EVENTSINK_MAP(CTreeDialog)
  68.     ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 3 /* Up */, OnUpMultibtnctrl1, VTS_NONE)
  69.     ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 4 /* Down */, OnDownMultibtnctrl1, VTS_NONE)
  70.     ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 1 /* Left */, OnLeftMultibtnctrl1, VTS_NONE)
  71.     ON_EVENT(CTreeDialog, IDC_MULTIBTNCTRL1, 2 /* Right */, OnRightMultibtnctrl1, VTS_NONE)
  72.     ON_EVENT(CTreeDialog, IDC_BUTTON1, -600 /* Click */, OnClickButton1, VTS_NONE)
  73.     ON_EVENT(CTreeDialog, IDC_TREEVIEW1, -602 /* KeyDown */, OnKeyDownTreeview1, VTS_PI2 VTS_I2)
  74.     //}}AFX_EVENTSINK_MAP
  75. END_EVENTSINK_MAP()
  76.  
  77. void CTreeDialog::OnUpMultibtnctrl1()
  78. {
  79.     // TODO: Add your control notification handler code here
  80.     CBranch Selected;
  81.  
  82.     Selected = m_treeview.GetBranches().Get(pvtGetNextSelected,0);
  83.     if (Selected.IsValid())
  84.     {
  85.         // gets the prev visible item
  86.         Selected = Selected.Get(pvtGetPrevVisible,0);
  87.  
  88.         // selects the item
  89.         Selected.Select(pvtNode);
  90.     }
  91.     else
  92.     {
  93.         Selected = m_treeview.GetBranches().Get(pvtGetChild, 0);
  94.         if (Selected.IsValid())
  95.             Selected.Select(pvtNode);
  96.     }
  97. }
  98.  
  99. void CTreeDialog::OnDownMultibtnctrl1()
  100. {
  101.     // TODO: Add your control notification handler code here
  102.     CBranch Selected;
  103.  
  104.     // gets the currently selected item
  105.     Selected = m_treeview.GetBranches().Get(pvtGetNextSelected,0);
  106.  
  107.     if (Selected.IsValid())
  108.     {
  109.         // gets the next visible item
  110.         Selected = Selected.Get(pvtGetNextVisible,0);
  111.  
  112.         // selects the item
  113.         Selected.Select(pvtNode);
  114.     }
  115.     else
  116.     {
  117.         Selected = m_treeview.GetBranches().Get(pvtGetChild, 0);
  118.         if (Selected.IsValid())
  119.             Selected.Select(pvtNode);
  120.     }
  121. }
  122.  
  123. void CTreeDialog::OnLeftMultibtnctrl1()
  124. {
  125.     // TODO: Add your control notification handler code here
  126.     CBranch Selected;
  127.  
  128.     Selected = m_treeview.GetBranches().Get(pvtGetNextSelected, 0);
  129.     if (!Selected.IsValid())
  130.         return;
  131.  
  132.     Selected.Clear();
  133.     Selected.Remove();
  134. }
  135.  
  136. void CTreeDialog::OnRightMultibtnctrl1()
  137. {
  138.     // TODO: Add your control notification handler code here
  139.     CBranch Selected;
  140.  
  141.     Selected = m_treeview.GetBranches().Get(pvtGetNextSelected, 0);
  142.     if (!Selected.IsValid())
  143.         return;
  144.  
  145.     Selected.Add(pvtPositionInOrder, 0, "Newly inserted Child Node");
  146. }
  147.  
  148. void CTreeDialog::OnClickButton1() 
  149. {
  150.     // TODO: Add your control notification handler code here
  151.     m_treeview.GetBranches().Add(pvtPositionInOrder, 0, "New Parent Node");
  152. }
  153.  
  154. void CTreeDialog::OnKeyDownTreeview1(short FAR* KeyCode, short Shift) 
  155. {
  156.     // TODO: Add your control notification handler code here
  157.     if (*KeyCode == VK_RETURN)
  158.         m_treeview.BeginInPlaceEdit();    
  159.     
  160. }
  161.